package io.renren.timeWheel;

import io.renren.RenrenApplication;
import io.renren.modules.avanotes.component.TimeWheelComponent;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author: xiaomi
 * @date: 2022/2/22
 * @description: 测试时间轮：可以用 Runnable！
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RenrenApplication.class)
@Slf4j
public class WorkTask {


    @Autowired
    TimeWheelComponent timeWheel;

    //2022-02-22 22:11:36.771  INFO 244800 --- [           main] io.renren.timeWheel.WorkTask             : start!
    //2022-02-22 22:13:16.872  INFO 244800
    @Test
    public void testTimeWheel() {
        timeWheel.addTask(20, () -> {
            log.info("time up!");
        });
        log.info("start!");
        while (true) {

        }
    }
}
